<template>
  <div class="page-open-container" :class="mivaShow&&'miva-show'">
    <div class="center-container">
      <!-- 标题 -->
      <div class="title-container">
        <p>you &</p>
        <span>me</span>
        <span>interact</span>
        <div class="zh-cn">有安米互动</div>
      </div>
      <!-- 书本 -->
      <div class="block-container">
        <div v-for="(temp, index) in itemList" :key="index" @click="clickHandler(temp.router)">
          <span>{{ temp.title }}</span>
        </div>
      </div>
    </div>
    <div v-show="mivaShow">
      <!-- 锁链 -->
      <div class="suolian">
        <span v-for="temp in 2" :key="temp" />
      </div>
      <!-- 齿轮 -->
      <img class="icon-asc" src="@/assets/chilun.png">
      <img class="icon-desc-1" src="@/assets/chilun.png">
      <img class="icon-desc-2" src="@/assets/chilun.png">
    </div>
    <!-- 九条米法 -->
    <!-- <div class="about-me">- Kujo Miva -</div> -->
    <div class="item-switch">
      <vanSwitch v-model="mivaOff" size="24px" active-color="#cfa23e" inactive-color="#2e404e" @change="changeHandler" />
      <div>是否开启效果 ( {{ mivaOff?'开启':'关闭' }} )</div>
    </div>
  </div>
</template>

<script>
import { Switch } from 'vant'
export default {
  components: {
    vanSwitch: Switch
  },
  data() {
    return {
      mivaOff: false,
      itemList: [
        { title: 'H5', router: 'html5' },
        { title: '长图简漫', router: 'longImage' },
        { title: '宣传海报', router: 'poster' },
        { title: '动态视频', router: 'video' }
      ]
    }
  },
  computed: {
    mivaShow() {
      return this.$store.state.mivaShow
    }
  },
  created() {
    this.mivaOff = this.$store.state.mivaShow
  },
  methods: {
    changeHandler(checked) {
      this.$store.commit('TOOGELMIVASHOW')
      console.log(this.mivaShow)
    },
    clickHandler(wantTo) {
      // alert(`I Want To ${wantTo}`)
      this.$router.goTo(this, `/${wantTo}`)
    }
  }
}
</script>

// 动画组样式
<style lang="scss">
@mixin icon {
  width: 100px;
  position: absolute;
  opacity: 0.8;
}
@keyframes run-asc {
  0% {
    transform: rotateZ(-45deg) translate(-900px, 35px);
  }
  100% {
    transform: rotateZ(-45deg) translate(-200px, 35px);
  }
}
@keyframes rotate-asc {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
@keyframes rotate-desc {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(-360deg);
  }
}
.miva-show{
  .suolian {
    span {
      width: 1000px;
      position: absolute;
      top: -333px;
      display: inline-block;
      border: 3px dashed #b57e46;
    }
    span:nth-child(1) {
      left: -55px;
      animation: run-asc 30s infinite linear alternate;
    }
    span:nth-child(2) {
      left: -60px;
      animation: run-asc 30s infinite linear alternate;
    }
  }
  .icon-asc {
    @include icon;
    right: -40px;
    bottom: -40px;
    animation: rotate-asc 5s infinite linear;
  }
  .icon-desc-1 {
    @include icon;
    right: 50px;
    bottom: -65px;
    animation: rotate-desc 5s infinite linear;
  }
  .icon-desc-2 {
    @include icon;
    right: -65px;
    bottom: 50px;
    animation: rotate-desc 5s infinite linear;
  }
}
</style>
// 架构组样式
<style lang="scss">
.page-open-container {
  width: 100%;
  height: 100%;
  padding: 15px;
  text-align: center;
  font-weight: bold;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
  background-color: #2e404e;
  color: #cfa23e;
  .center-container {
    margin: auto;
    position: relative;
    z-index: 99;
  }
  .item-switch {
    position: absolute;
    bottom: 10px;
    font-size: 12px;
  }
  .title-container {
    font-size: 18px;
    position: relative;
    white-space: nowrap;
    text-shadow: 2px 2px 0px #2e404e;
    p {
      display: inline-block;
      margin: 0;
      font-family: "KujoMiva";
    }
    p:first-letter {
      font-size: 2.3rem;
      vertical-align: middle;
    }
    span:nth-child(2) {
      position: relative;
      top: 15px;
      left: -30px;
      font-family: "KujoMiva";
    }
    span:nth-child(3) {
      font-size: 2.3rem;
      text-transform: uppercase;
      vertical-align: -webkit-baseline-middle;
    }
    .zh-cn {
      width: 60%;
      margin: auto;
      padding: 10px;
      border-bottom: 10px double;
    }
  }
  .block-container {
    max-width: 380px;
    margin: 30px auto 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    div {
      width: 7rem;
      height: 10rem;
      margin: 10px;
      display: flex;
      align-items: center;
      border: 10px double;
      border-radius: 0 10px 10px 0;
      span {
        width: 90%;
        padding: 5px 0;
        position: relative;
        left: -10px;
        display: inline-block;
        border-radius: 0 30px 30px 0;
        box-sizing: content-box;
        border: 10px double;
        border-left: 0;
        background-color: #cfa23e;
        color: #2e404e;
      }
    }
  }
  .about-me {
    position: absolute;
    bottom: 5px;
    left: 5px;
    z-index: 748943649;
    font-size: 12px;
    text-shadow: 2px 2px 0px #2e404e;
  }
}
</style>
